package com.weblog.model.article;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

/**
 * article实体类
 * @author Administrator
 *
 */
@Entity
@Table(name="tb_article")
public class Article implements Serializable{

	private static final long serialVersionUID=-5678920398272943999L;

	/**
	 * 文章id
	 */
	@Id
	private String aid;


	/**
	 * 用户id
	 */
	private String userid;
	/**
	 * 文章标题
	 */
	private String title;
	/**
	 * content_md
	 */
	@Column(name = "contentMd")
	private String contentMd;

	/**
	 * 文章内容html格式
	 */
	@Column(name = "contentHtml")
	private String contentHtml;

	/**
	 * 发布时间
	 */
	private Date publishtime;

	/**
	 * 最后更新时间
	 */
	private Date lastupdate;
	/**
	 * 是否公开
	 */
	private String ispublic;
	/**
	 * 是否热门
	 */
	private String ishot;
	/**
	 * 点赞数
	 */
	private Long thumbup;
	/**
	 * 评论数
	 */
	private Integer commentnum;
	/**
	 * 审核状态 1通过 0未审核或审核未通过
	 */
	private String state;
	/**
	 * 是否允许评论
	 */
	private String iscomment;
	/**
	 * 是否置顶，此为在用户文章列表是否置顶显示
	 */
	private String istop;



	@JsonIgnoreProperties(value = {"articles"})
	@ManyToMany(targetEntity = Tag.class,fetch = FetchType.EAGER)
	@JoinTable(name = "tb_ta",
			joinColumns = {@JoinColumn(name = "articleid",referencedColumnName = "aid")},
			inverseJoinColumns = {@JoinColumn(name = "tagid",referencedColumnName = "id")})
	private Set<Tag> tags=new HashSet<>();


	@Override
	public String toString() {
		return "Article{" +
				"aid='" + aid + '\'' +
				//", categoryName='" + categoryName + '\'' +
				//", clevel=" + clevel +
				", userid='" + userid + '\'' +
				", title='" + title + '\'' +
				", contentMd='" + contentMd + '\'' +
				", contentHtml='" + contentHtml + '\'' +
				", publishtime=" + publishtime +
				", lastupdate=" + lastupdate +
				", ispublic='" + ispublic + '\'' +
				", ishot='" + ishot + '\'' +
				", thumbup=" + thumbup +
				", commentnum=" + commentnum +
				", state='" + state + '\'' +
				", iscomment='" + iscomment + '\'' +
				", istop='" + istop + '\'' +
				//", cid1='" + cid1 + '\'' +
				//", cids='" + cids + '\'' +
				", tags=" + tags +
				'}';
	}


	public Article() {
	}

	public String getIstop() {
		return istop;
	}

	public void setIstop(String istop) {
		this.istop = istop;
	}

	public Set<Tag> getTags() {
		return tags;
	}

	public void setTags(Set<Tag> tags) {
		this.tags = tags;
	}

	public String getAid() {
		return aid;
	}
	public void setAid(String aid) {
		this.aid = aid;
	}





	public String getUserid() {
		return userid;
	}
	public void setUserid(String userid) {
		this.userid = userid;
	}

	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}

	public String getContentMd() {
		return contentMd;
	}
	public void setContentMd(String contentMd) {
		this.contentMd = contentMd;
	}

	public String getContentHtml() {
		return contentHtml;
	}
	public void setContentHtml(String contentHtml) {
		this.contentHtml = contentHtml;
	}

	public Date getPublishtime() {
		return publishtime;
	}
	public void setPublishtime(Date publishtime) {
		this.publishtime = publishtime;
	}

	public Date getLastupdate() {
		return lastupdate;
	}
	public void setLastupdate(Date lastupdate) {
		this.lastupdate = lastupdate;
	}

	public String getIspublic() {
		return ispublic;
	}
	public void setIspublic(String ispublic) {
		this.ispublic = ispublic;
	}

	public String getIshot() {
		return ishot;
	}

	public void setIshot(String ishot) {
		this.ishot = ishot;
	}

	public Long getThumbup() {
		return thumbup;
	}
	public void setThumbup(Long thumbup) {
		this.thumbup = thumbup;
	}

	public Integer getCommentnum() {
		return commentnum;
	}
	public void setCommentnum(Integer commentnum) {
		this.commentnum = commentnum;
	}

	public String getState() {
		return state;
	}
	public void setState(String state) {
		this.state = state;
	}

	public String getIscomment() {
		return iscomment;
	}
	public void setIscomment(String iscomment) {
		this.iscomment = iscomment;
	}


	
}
